﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Linq.Expressions;
using SelfMadeMillionaire.Core;
using SelfMadeMillionaire.Core.Entities;
using SelfMadeMillionaire.Core.Enums;
using SelfMadeMillionaire.Core.Repositories;
using SelfMadeMillionaire.Core.Services;
using SelfMadeMillionaire.Core.Specifications;

namespace SelfMadeMillionaire.BLL.Services
{
	public class UserPortfolioService : IUserPortfolioService
	{
		private readonly IUserPortfolioRepository _portfolioRepository;

		public UserPortfolioService(IUserPortfolioRepository PortfolioRepository)
		{
			_portfolioRepository = PortfolioRepository;
		}

        public IEnumerable<UserPortfolio> GetAll(int subscriberId)
        {
            return _portfolioRepository.GetAll(x => x.Subscriber.ID == subscriberId);
        }

        public IEnumerable<UserPortfolio> GetAll(Expression<Func<UserPortfolio, bool>> predicate)
        {
            return _portfolioRepository.GetAll(predicate);
        }

        public UserPortfolio Add(UserPortfolio item)
		{
            return _portfolioRepository.Add(item);
		}

        public UserPortfolio Update(UserPortfolio item)
		{
            return _portfolioRepository.Update(item);
		}

        public UserPortfolio Get(int id)
		{
			return _portfolioRepository.Get(id);
		}
        
		public void Remove(int id)
		{
            _portfolioRepository.Remove(id);
		}
	}
}